package edu.ccit.shudong.controller;

import edu.ccit.shudong.dto.MessageDTO;
import edu.ccit.shudong.dto.PostDTO;
import edu.ccit.shudong.dto.UserProfileDTO;
import edu.ccit.shudong.entity.Comment;
import edu.ccit.shudong.entity.Message;
import edu.ccit.shudong.service.IMessageService;
import edu.ccit.shudong.service.impl.MessageServiceImpl;
import edu.ccit.shudong.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Suting Luo
 * @since 2024-10-09
 */
@RestController
@RequestMapping("/message")

@Api(tags="信息")
public class MessageController {
    @Resource
    private IMessageService messageService;

    @ApiOperation("信息读取")
    @GetMapping("")
    public Object getList(HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        PostDTO posts = messageService.getProfileByToken(token);
        return posts != null ? R.ok("成功", posts) : R.error("失败");
    }

//    @ApiOperation("添加信息")
//    @PostMapping("/")
//    public void addMessage(@RequestBody Message message) {
//        messageService.addMessage(message);
//    }
}
